home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-15 | 8.0 KB | 190 lines | [TEXT/SPM ] |
- #include <MixedMode.r>
- #include <FatRSRC.r>
-
- #define FAT 1
- #define SAFE 1
- #define SAFER 1
- #define CURRENTISA 0
- #define SHRINKING 1
-
- #define ResType 'CODE' // Change to the type of resource you wish to create
- #define ResID 300 // Change to the ID of resource you wish to create
- #define ResName "Syslog Component (Fat)" // Change to the name of the resource you wish to create
-
- #define PPCResFile "Syslog.π.rsrc" // Change to the name of this project's resource file
- #define PPCProcInfo $000003F0 // Change to ProcInfo value for your resource's PowerPC code
-
- #define M68KResFile "68K Syslog code.rsrc" // If FAT, Change to name of the file to merge a 68K resource from
- #define M68KResType 'CODE' // If FAT, Change to the type of 68K resource to merge in
- #define M68KResID 301 // If FAT, Change to the ID of 68K resource to merge in
-
- #define M68KProcInfo $0 // Change to ProcInfo value for your fat resource's 68K code
-
- /*
- Prepend a routine descriptor (from a 'rdes', 'fdes', 'Fdes', 'sdes', 'Sdes', 'ades', 'Ades' or
- '<des' template) to our temporary resource and store it into a resource with the type and ID
- specified by ResType and ResID.
-
- • Change the ResType and ResID macros to the resource type and ID you wish to create.
-
- • Change the PPCResFile macro to the name of this project's resource file.
-
- • Change the PPCProcInfo macro to the ProcInfo value for your resource's PowerPC code.
-
- • If creating a "Fat" code resource, change the M68KResFile macro to the name of the file to
- merge a 68K resource from.
-
- • If creating a "Fat" code resource, change the M68KResType and M68KResID macros to the
- resource type and ID of a 68K resource to merge in.
-
- • If creating a "Fat" code resource, change the M68KProcInfo macro to the ProcInfo value for
- your 68K code.
-
-
- Accelerated (native PowerPC) Code Resource ('rdes' template) :
-
- Set FAT to 0 to build an accelerated (native PowerPC) code resource with the 'rdes' template.
- Resources created with this template can be executed on a PowerMac from either PowerPC or
- 68K mode. Calling the resource from 68K code (in emulation) will cause a mode switch.
- Resources created with this template are unusable on 68K Macs.
-
- Fat Code Resource ('fdes' template) :
-
- Set FAT to 1, SAFE to 0, and CURRENTISA to 0 to build a "Fat" code resource with the 'fdes'
- template. If a resource created with this template is used on a 68K Mac, the 68K portion of the
- code resource will be executed. If it's used on a PowerMac, the PowerPC portion of the code
- resource will be executed. You would use this template if, when running on a PowerMac in 68K
- emulation, there is less overhead switching to PowerPC mode and executing your PowerPC code
- than executing your 68K code. Resources created with this template require the Mixed Mode
- Manager to run on a 68K Mac.
-
- Fat Code Resource dependant on current mode ('Fdes' template) :
-
- Set FAT to 1, SAFE to 0, and CURRENTISA to 1 to build a "Fat" code resource, which is dependant
- on the current mode, with the 'Fdes' template. Code resources created with this template will
- minimize mode switches by executing your PowerPC code if called by PowerPC code (not in 68K
- emulation), and executing your 68K code if called in emulation (or on a 68K Mac). You would use
- this template if, when running on a PowerMac in 68K emulation, there is less overhead executing
- your 68K code than switching modes and executing your PowerPC code. Only use this template if
- your code resource, when running on a PowerMac, might be executed by either 68K or PowerPC
- code. Resources created with this template require the Mixed Mode Manager to run on a 68K Mac.
-
- Safe Fat Code Resource ('sdes' template) :
-
- Set FAT to 1, SAFE to 1, SAFER to 0, SHRINKING to 0, and CURRENTISA to 0 to build a "Safe
- Fat" code resource with the 'sdes' template. Code resources created with this template are
- similar to those created by the 'fdes' template (described above), but will run on a 68K Mac
- with or without the Mixed Mode Manager.
-
- Safe Fat Code Resource dependant on current mode ('Sdes' template) :
-
- Set FAT to 1, SAFE to 1, SAFER to 0, SHRINKING to 0, and CURRENTISA to 1 to build a "Safe
- Fat" code resource, which is dependant on the current mode, with the 'Sdes' template. Code
- resources created with this template are similar to those created with the 'Fdes' template
- (described above), but will run on a 68K Mac with or without the Mixed Mode Manager.
-
- Safer Fat Code Resource ('ades' template) :
-
- Set FAT to 1, SAFE to 1, SAFER to 1, SHRINKING to 0, and CURRENTISA to 0 to build a "Safer
- Fat" code resource with the 'ades' template. Code resources created with this template are
- similar to those created with the 'sdes' template (described above). The 'sdes' template was
- inherited from MPW. We provide a "Safer" code resource template to work around some
- potential problems with the 'sdes' template. Code resources created with this template support
- register-based calling conventions, and 68K Macs without instruction caches.
-
- Safer Fat Code Resource dependant on current mode ('Ades' template) :
-
- Set FAT to 1, SAFE to 1, SAFER to 1, SHRINKING to 0, and CURRENTISA to 1 to build a "Safer
- Fat" code resource, which is dependant on the current mode, with the 'Ades' template. Code
- resources created with this template are similar to those created with the 'Sdes' template
- (described above), but works around some potential problems with it. Code resources created
- with this template supports register-based calling conventions, and 68K Macs without
- instruction caches.
-
- Shrinking Safe Fat Code Resource ('<des' template) :
-
- Set FAT to 1, SAFE to 1, and SHRINKING to 1 to create a "Shrinking Safe Fat" code resource
- with the '<des' template. You would use this template if, when running on a PowerMac in
- 68K emulation, there is less overhead switching to PowerPC mode and executing your
- PowerPC code than executing your 68K code. This resource will determine what type of Mac
- you are using. If you are using a 68K Mac, the PowerPC code will be truncated from the end
- of the resource in memory. If you are using a PowerMac, the PowerPC code will be moved to
- the start of the resource, and the left-over space will be truncated from the end of the
- resource in memory. This type of resource will run natively to either platform, and will not
- keep unused code in memory.
-
-
- !!! Beware, the 68K register A0 will not point to the start of your resource upon entry. Some
- !!! 68K code resources rely on this. For example, many INIT's pass A0 to RecoverHandle, to get a
- !!! Handle to their code, to detach it (with DetachResource) from its resource file. Instead, INIT's
- !!! should use Get1Resource to get this Handle.
- !!!
- !!! The SetUpA4-related routines will work properly in the 68K code of a "Fat" resource.
-
- • This file does not set any resource attributes for your code resource. You must specify your
- resource attributes below (ala Rez), or set them once your resource is built, with ResEdit.
-
- • To create your code resource, simply bring this project up to date. You do not need to
- generate a target. Your code resource will be saved to your project's resource file.
-
- • This file must be compiled AFTER "_CopyToResource.r"
-
- Colen Garoutte-Carson
- Symantec Corp.
- */
-
- #if FAT
- #if SAFE
- #if SHRINKING
- type ResType as '<des';
- #else
- #if SAFER
- #if CURRENTISA
- type ResType as 'Ades';
- #else
- type ResType as 'ades';
- #endif
- #else
- #if CURRENTISA
- type ResType as 'Sdes';
- #else
- type ResType as 'sdes';
- #endif
- #endif
- #endif
- #else
- #if CURRENTISA
- type ResType as 'Fdes';
- #else
- type ResType as 'fdes';
- #endif
- #endif
- #else
- type ResType as 'rdes';
- #endif
-
- resource ResType (ResID,ResName) {
- #if FAT
- #if SAFE
- #if !SHRINKING
- M68KProcInfo,
- PPCProcInfo,
- #endif
- #else
- M68KProcInfo,
- PPCProcInfo,
- #endif
- #else
- PPCProcInfo,
- #endif
- #if FAT
- $$Resource(M68KResFile, M68KResType, M68KResID),
- #if SAFE
- #if SHRINKING
- PPCProcInfo,
- #endif
- #endif
- #endif
- $$Resource(PPCResFile, 'TEMP', 0)
- };
-